var ECharts;
$(document).ready(function () {

    require.config({
        baseUrl: ctx + '/resource/plugins/echarts4',
        paths: {
            echarts: 'echarts',
            roma: 'theme/roma',
        }
    });
    require(
        [
            'echarts',
            'roma'
        ],
        function (ec) {
            ECharts = ec;
            HostInformationViewController();//主机基本信息

            host_ping_ybp = ECharts.init(document.getElementById('host_ping_ybp'), 'roma');//ping结果
            queryHostPing();

            host_syslog_ybp = ECharts.init(document.getElementById('host_syslog_ybp'), 'roma');//syslog状态
            queryHostSyslog();

            host_cpu_syl_zxt = ECharts.init(document.getElementById('host_cpu_syl_zxt'), 'roma');//CPU使用率
            queryHostCpu();

            host_cpu_dzt = ECharts.init(document.getElementById('host_cpu_dzt'), 'roma');//CPU柱状图
            queryHostCpuDzt();

            host_nc_syl_zxt = ECharts.init(document.getElementById('host_nc_syl_zxt'), 'roma');//物理内存使用率
            queryHostNc();

            host_nc_dzt = ECharts.init(document.getElementById('host_nc_dzt'), 'roma');//内存倒状图
            queryHostNcDzt();

            host_cp_syl_zxt = ECharts.init(document.getElementById('host_cp_syl_zxt'), 'roma');//磁盘总使用率
            queryHostCp();

            host_cp_dzt = ECharts.init(document.getElementById('host_cp_dzt'), 'roma');//磁盘倒状图
            queryHostCpDzt();

            // host_wjxt_syl_zzt = ECharts.init(document.getElementById('host_wjxt_syl_zzt'), 'roma');//文件系统使用率
            // queryHostWjxt();
        }
    );
    // queryCp();//磁盘信息
    // queryLjjInfo();//逻辑卷状态信息
    // queryCpu();//CPU状态信息
    // queryHPageInfo();//换页空间信息
});
var cpList = [];//磁盘信息
cpList.push("PM-00-01-003-03");
cpList.push("PM-00-01-003-01");
//===================================
var ljjList = [];//逻辑卷状态信息
ljjList.push("FM-00-01-001-14");
//====================================
var cpuStateList = [];//CPU状态信息
cpuStateList.push("FM-00-01-001-15");
//=====================================
var pageList = [];//换页空间信息
pageList.push("PM-00-01-001-19");
pageList.push("PM-00-01-001-20");
pageList.push("PM-00-01-001-21");
pageList.push("PM-00-01-001-22");
pageList.push("PM-00-01-001-23");

var infoList = [];//主机基本信息
infoList.push("CM-00-01-001-01");
infoList.push("CM-00-01-001-03");
// infoList.push("CM-00-01-001-16");
// infoList.push("CM-00-01-001-20");
infoList.push("CM-00-02-001-05");
infoList.push("CM-00-04-006-05");
infoList.push("CM-00-04-006-10");
infoList.push("CM-00-04-009-11");
// infoList.push("CM-01-03-001-08");

// CM-00-04-009-11 KPI-linux-ALL-4 系统名称
// CM-00-01-001-20 KPI-linux-ALL-81  磁盘名称(key)
// CM-00-01-001-03 KPI-linux-ALL-5 操作系统类型
// CM-00-02-001-05 KPI-linux-ALL-2 管理IP
// CM-00-04-006-05 KPI-linux-ALL-7 硬件厂商
// CM-01-03-001-08 KPI-linux-ALL-8 设备标识号
// CM-00-01-001-16 KPI-linux-ALL-97  文件系统名(key)
// CM-00-04-006-10 KPI-linux-ALL-6 操作系统版本
// CM-00-01-001-01 KPI-linux-ALL-1 名称

/**主机基本信息*/
function HostInformationViewController() {
    var str = infoList.toString();
    $.ajax({
        url: ctx + "/load/queryInfo",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&RESU=" + str + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list = map["CM-00-01-001-01"];
            var list1 = map["CM-00-01-001-03"];
            // var list2 = map["CM-00-01-001-16"];
            // var list3 = map["CM-00-01-001-20"];
            var list4 = map["CM-00-02-001-05"];
            var list5 = map["CM-00-04-006-05"];
            var list6 = map["CM-00-04-006-10"];
            var list7 = map["CM-00-04-009-11"];
            // var list8 = map["CM-01-03-001-08"];
            var tablel = "";
            tablel += "<tr>" +
                "<th><span >" + "指标名" + "</span></th>" +
                "<th><span >" + "采集值" + "</span></th>" +
                "</tr>";
            if (list.length == 0) {
                tablel += "<tr>" +
                    "<td><span >" + "主机名称" + "</span></td>" +
                    "<td><span >" + "暂无数据" + "</span></td>" +
                    "</tr>";
            } else{
                tablel += "<tr>" +
                    "<td><span >" + list[0].KPI_NAME + "</span></td>" +
                    "<td><span >" + list[0].KPI_VALUE + "</span></td>" +
                    "</tr>";
            }
            if (list1.length == 0) {
                tablel += "<tr>" +
                    "<td><span >" + "主机类型" + "</span></td>" +
                    "<td><span >" + "暂无数据" + "</span></td>" +
                    "</tr>";
            } else {
                tablel += "<tr>" +
                    "<td><span >" + list1[0].KPI_NAME + "</span></td>" +
                    "<td><span >" + list1[0].KPI_VALUE + "</span></td>" +
                    "</tr>";
            }
            // if (list2.length == 0) {
            //     tablel += "<tr>" +
            //         "<td><span >" + "文件系统名称" + "</span></td>" +
            //         "<td><span >" + "暂无数据" + "</span></td>" +
            //         "</tr>";
            // } else {
            //     tablel += "<tr>" +
            //         "<td><span >" + list2[0].KPI_NAME + "</span></td>" +
            //         "<td><span >" + list2[0].KPI_VALUE + "</span></td>" +
            //         "</tr>";
            // }
            // if (list3.length == 0) {
            //     tablel += "<tr>" +
            //         "<td><span >" + "磁盘名称" + "</span></td>" +
            //         "<td><span >" + "暂无数据" + "</span></td>" +
            //         "</tr>";
            // } else {
            //     tablel += "<tr>" +
            //         "<td><span >" + list3[0].KPI_NAME + "</span></td>" +
            //         "<td><span >" + list3[0].KPI_VALUE + "</span></td>" +
            //         "</tr>";
            // }
            if (list4.length == 0) {
                tablel += "<tr>" +
                    "<td><span >" + "网元IP地址" + "</span></td>" +
                    "<td><span >" + "暂无数据" + "</span></td>" +
                    "</tr>";
            } else {
                tablel += "<tr>" +
                    "<td><span >" + list4[0].KPI_NAME + "</span></td>" +
                    "<td><span >" + list4[0].KPI_VALUE + "</span></td>" +
                    "</tr>";
            }
            if (list5.length == 0) {
                tablel += "<tr>" +
                    "<td><span >" + "厂商" + "</span></td>" +
                    "<td><span >" + "暂无数据" + "</span></td>" +
                    "</tr>";
            } else {
                tablel += "<tr>" +
                    "<td><span >" + list5[0].KPI_NAME + "</span></td>" +
                    "<td><span >" + list5[0].KPI_VALUE + "</span></td>" +
                    "</tr>";
            }
            if (list6.length == 0) {
                tablel += "<tr>" +
                    "<td><span >" + "操作系统版本" + "</span></td>" +
                    "<td><span >" + "暂无数据" + "</span></td>" +
                    "</tr>";
            } else {
                tablel += "<tr>" +
                    "<td><span >" + list6[0].KPI_NAME + "</span></td>" +
                    "<td><span >" + list6[0].KPI_VALUE + "</span></td>" +
                    "</tr>";
            }
            if (list7.length == 0) {
                tablel += "<tr>" +
                    "<td><span >" + "操作系统名称" + "</span></td>" +
                    "<td><span >" + "暂无数据" + "</span></td>" +
                    "</tr>";
            } else {
                tablel += "<tr>" +
                    "<td><span >" + list7[0].KPI_NAME + "</span></td>" +
                    "<td><span >" + list7[0].KPI_VALUE + "</span></td>" +
                    "</tr>";
            }
            // if (list8.length == 0) {
            //     tablel += "<tr>" +
            //         "<td><span >" + "设备序列号" + "</span></td>" +
            //         "<td><span >" + "暂无数据" + "</span></td>" +
            //         "</tr>";
            // } else {
            //     tablel += "<tr>" +
            //         "<td><span >" + list8[0].KPI_NAME + "</span></td>" +
            //         "<td><span >" + list8[0].KPI_VALUE + "</span></td>" +
            //         "</tr>";
            // }

            $("#host_info").append(tablel);
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


/**PING结果*/
//PM-00-00-000-02
function queryHostPing() {
    $.ajax({
        url: ctx + "/load/queryNum",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-00-000-02" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var mydata;
            var cpuState = JSON.parse(data);
            for (var i = 0; i < cpuState.length; i++) {
                var a = cpuState[i].SUCCESS_VALUE;
                var b = cpuState[i].COUNT_VALUE;
            }
            option = {
                tooltip: {
                    formatter: "{a} <br/>{b} : {c}%"
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: {show: true},
                        // restore: {show: true},
                        // saveAsImage: {show: true}
                    }
                },
                series: [
                    {
                        name: '',
                        type: 'gauge',
                        splitNumber: 10,       // 分割段数，默认为5
                        axisLine: {            // 坐标轴线
                            lineStyle: {       // 属性lineStyle控制线条样式
                                color: [[0.2, '#ff4500'], [0.8, '#48b'], [1, '#228b22']],//
                                width: 8
                            }
                        },
                        axisTick: {            // 坐标轴小标记
                            splitNumber: 10,   // 每份split细分多少段
                            length: 12,        // 属性length控制线长
                            lineStyle: {       // 属性lineStyle控制线条样式
                                color: 'auto'
                            }
                        },
                        axisLabel: {           // 坐标轴文本标签，详见axis.axisLabel
                            textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                color: 'auto'
                            }
                        },
                        splitLine: {           // 分隔线
                            show: true,        // 默认显示，属性show控制显示与否
                            length: 30,         // 属性length控制线长
                            lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                                color: 'auto'
                            }
                        },
                        pointer: {
                            width: 5
                        },
                        title: {
                            show: true,
                            offsetCenter: [0, '-40%'],       // x, y，单位px
                            textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                fontWeight: 'bolder'
                            }
                        },
                        detail: {
                            formatter: '{value}%',
                            textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                color: 'auto',
                                fontWeight: 'bolder'
                            }
                        },
                        data: []
                    }
                ]
            };//仪表盘结束
            var cpuName = "";
            var succ = [];
            var sun = [];
            var p_value = 0;
            var q_value = 0;
            var succs = 0;
            var sums = 0;
            if (DATE_TYPE == "showYear") {
                for (var j = 0; j < cpuState.length; j++) {
                    p_value = parseInt(cpuState[j].SUCCESS_VALUE);
                    succ.push(p_value);
                    q_value = parseInt(cpuState[j].COUNT_VALUE);
                    sun.push(q_value);
                    cpuName = cpuState[j].KPI_NAME;
                }
                for (var k = 0; k < succ.length; k++) {
                    succs += succ[k];
                    sums += sun[k];
                }
                /*alert(succs);alert(sums);*/
                mydata = [{value: parseInt(succs / sums * 100), name: cpuName}];
            } else {
                for (var i = 0; i < cpuState.length; i++) {
                    mydata = [{
                        value: parseInt(cpuState[i].SUCCESS_VALUE / cpuState[i].COUNT_VALUE * 100),
                        name: cpuState[i].KPI_NAME
                    }];
                }
            }
            if (a == undefined || b == undefined) {
                var table = "<h3 style='margin-top: 180px;padding-left: 140px;'>" + "暂无数据" + "</h3>";
                $("#host_ping_ybp").html(table);
            } else {
                option.series[0].data = mydata;
                host_ping_ybp.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });

}


//syslog状态
//FM-00-01-001-16
function queryHostSyslog() {
    $.ajax({
        url: ctx + "/load/queryNum",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-00-000-02" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var mydata;
            var Syslog = JSON.parse(data);
            for (var i = 0; i < Syslog.length; i++) {
                var a = Syslog[i].SUCCESS_VALUE;
                var b = Syslog[i].COUNT_VALUE;
            }
            option = {
                tooltip: {
                    formatter: "{a} <br/>{b} : {c}%"
                },
                toolbox: {
                    show: true,
                    feature: {
                        mark: {show: true},
                        // restore: {show: true},
                        // saveAsImage: {show: true}
                    }
                },
                series: [
                    {
                        name: '',
                        type: 'gauge',
                        splitNumber: 10,       // 分割段数，默认为5
                        axisLine: {            // 坐标轴线
                            lineStyle: {       // 属性lineStyle控制线条样式
                                color: [[0.2, '#ff4500'], [0.8, '#48b'], [1, '#228b22']],//
                                width: 8
                            }
                        },
                        axisTick: {            // 坐标轴小标记
                            splitNumber: 10,   // 每份split细分多少段
                            length: 12,        // 属性length控制线长
                            lineStyle: {       // 属性lineStyle控制线条样式
                                color: 'auto'
                            }
                        },
                        axisLabel: {           // 坐标轴文本标签，详见axis.axisLabel
                            textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                color: 'auto'
                            }
                        },
                        splitLine: {           // 分隔线
                            show: true,        // 默认显示，属性show控制显示与否
                            length: 30,         // 属性length控制线长
                            lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
                                color: 'auto'
                            }
                        },
                        pointer: {
                            width: 5
                        },
                        title: {
                            show: true,
                            offsetCenter: [0, '-40%'],       // x, y，单位px
                            textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                fontWeight: 'bolder'
                            }
                        },
                        detail: {
                            formatter: '{value}%',
                            textStyle: {       // 其余属性默认使用全局文本样式，详见TEXTSTYLE
                                color: 'auto',
                                fontWeight: 'bolder'
                            }
                        },
                        data: []
                    }
                ]
            };//仪表盘结束
            var cpuName = "";
            var succ = [];
            var sun = [];
            var p_value = 0;
            var q_value = 0;
            var succs = 0;
            var sums = 0;
            if (DATE_TYPE == "showYear") {
                for (var j = 0; j < Syslog.length; j++) {
                    p_value = parseInt(Syslog[j].SUCCESS_VALUE);
                    succ.push(p_value);
                    q_value = parseInt(Syslog[j].COUNT_VALUE);
                    sun.push(q_value);
                    cpuName = Syslog[j].KPI_NAME;
                }
                for (var k = 0; k < succ.length; k++) {
                    succs += succ[k];
                    sums += sun[k];
                }
                /*alert(succs);alert(sums);*/
                mydata = [{value: parseInt(succs / sums * 100), name: cpuName}];
            } else {
                for (var i = 0; i < Syslog.length; i++) {
                    mydata = [{
                        value: parseInt(Syslog[i].SUCCESS_VALUE / Syslog[i].COUNT_VALUE * 100),
                        name: Syslog[i].KPI_NAME
                    }];
                }
            }

            if (a == undefined || b == undefined) {
                var table = "<h3 style='margin-top: 180px;padding-left: 140px;'>" + "暂无数据" + "</h3>";
                $("#host_syslog_ybp").html(table);
            } else {
                option.series[0].data = mydata;
                host_syslog_ybp.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });

}


//CPU使用率折线图
//PM-00-01-001-11
function queryHostCpu() {
    $.ajax({
        url: ctx + "/load/queryLoad",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-001-11" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        // data:{"EXT_UNIT_ID" : EXT_UNIT_ID , "KPI_CODE" : "PM-00-01-001-11", "DATE_TYPE" : DATE_TYPE},
        // data:{EXT_UNIT_ID:"EXT_UNIT_ID",KPI_CODE:"PM-00-01-001-11",DATE_TYPE:"DATE_TYPE"},
        success: function (data) {
            var map = JSON.parse(data);
            // var map = eval('(' + data + ')');
            var list = map.list;
            var listTb = map.listTb;
            var listHb = map.listHb;
            var xdata = [];
            var ydata1 = [];
            var ydata2 = [];
            var ydata3 = [];
            var x_value = [];
            for (var i = 0; i < list.length; i++) {
                var a = list[i].AVG_VALUE;
                var b = listTb[i].AVG_VALUE;
            }
            if (a == undefined || b == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_cpu_syl_zxt").html(table);
            } else {
                if (DATE_TYPE == "showWeek") {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[2]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                } else if (DATE_TYPE == "showMonth") {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[2]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                    /*  option.xAxis.axisLabel.formatter='{value} d';*/
                } else if (DATE_TYPE == "showYear") {
                    for (var i = 0; i < list.length; i++) {
                        // xdata.push(list[i].DATA_TIME);
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[1]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        /* ydata3.push(listHb[i].AVG_VALUE);*/
                    }
                } else {
                    for (var i = 0; i < list.length; i++) {
                        // xdata.push(list[i].DATA_TIME);2018-01-01 09
                        x_value = list[i].DATA_TIME.replace(' ', '-').split("-");
                        xdata.push(x_value[3]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                }
                option = {
                    tooltip: {
                        trigger: 'axis',
                    },
                    legend: {
                        data: ['昨日', '同比', '环比'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            /*formatter:'{value} h',*/
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        data: xdata
                    }],
                    yAxis: [{
                        type: 'value',
                        max: 100,//Y轴最大值 不写的话自动调节
                        axisLabel: {
                            formatter: '{value} %',
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        }
                    }],
                    series: [
                        {
                            name: '昨日',
                            type: 'line',
                            color: '#EFB700',
                            data: ydata1
                        },
                        {
                            name: '同比',
                            type: 'line',
                            color: '#FF0A0E',
                            data: ydata2
                        },
                        {
                            name: '环比',
                            type: 'line',
                            color: '#0AFFBD',
                            data: ydata3
                        }
                    ]
                };

                host_cpu_syl_zxt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


//CPU使用率柱状图
//PM-00-01-001-11
function queryHostCpuDzt() {
    $.ajax({
        url: ctx + "/load/queryNum",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-001-11" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var memoryNum = JSON.parse(data);
            var xdata = [];
            var num1 = '';
            var min_value = '';
            var max_value = '';
            var group = '';
            var p = [];
            var values = [];
            var result = [0, 0, 0, 0, 0];
            var temp = '';
            var temp1 = '';
            var hkh = '';
            var myMap = new Map();
            var sum = 0;
            for (var i = 0; i < memoryNum.length; i++) {
                var a = memoryNum[i].GROUP_VALUE;
            }
            if (a == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_cpu_dzt").html(table);
            } else {
                if (DATE_TYPE != "showYear") {//，分割分完的截取每个元素的倒数第一个或者第二个双引号的值{"0.0~20.0":"289"，"20.0~40.0":"290，"40.0~60.0":"291"}
                    for (var i = 0; i < memoryNum.length; i++) {
                        hkh = memoryNum[i].GROUP_VALUE.substring(1, memoryNum[i].GROUP_VALUE.lastIndexOf('}'));
                        num1 = hkh.split(',');
                        min_value = memoryNum[i].Y_MIN_VALUE;
                        max_value = memoryNum[i].Y_MAX_VALUE;
                        group = memoryNum[i].VALUE_GROUP;
                        for (j = 0; j < num1.length; j++) {
                            temp = num1[j].substring(num1[j].lastIndexOf(':"') + 2, num1[j].lastIndexOf('"'));
                            temp1 = num1[j].substring(1, num1[j].lastIndexOf('":'));
                            myMap.set(temp1, temp);
                        }
                        if (myMap.get("0.0~20.0") != null) {
                            xdata.push(myMap.get("0.0~20.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("20.0~40.0") != null) {
                            xdata.push(myMap.get("20.0~40.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("40.0~60.0") != null) {
                            xdata.push(myMap.get("40.0~60.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("60.0~80.0") != null) {
                            xdata.push(myMap.get("60.0~80.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("80.0~100.0") != null) {
                            xdata.push(myMap.get("80.0~100.0"));
                        } else {
                            xdata.push(0);
                        }
                    }
                } else {
                    for (var i = 0; i < memoryNum.length; i++) {
                        hkh = memoryNum[i].GROUP_VALUE.substring(1, memoryNum[i].GROUP_VALUE.lastIndexOf('}'));
                        num1 = hkh.split(',');
                        min_value = memoryNum[i].Y_MIN_VALUE;
                        max_value = memoryNum[i].Y_MAX_VALUE;
                        group = memoryNum[i].VALUE_GROUP;
                        for (var j = 0; j < num1.length; j++) {
                            temp = num1[j].substring(num1[j].lastIndexOf(':"') + 2, num1[j].lastIndexOf('"'));
                            temp1 = num1[j].substring(1, num1[j].lastIndexOf('":'));
                            if (temp) {
                                sum = parseInt(sum) + parseInt(temp);
                            }
                            myMap.set(temp1, sum);
                        }
                    }
                    if (myMap.get("0.0~20.0") != null) {
                        xdata.push(myMap.get("0.0~20.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("20.0~40.0") != null) {
                        xdata.push(myMap.get("20.0~40.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("40.0~60.0") != null) {
                        xdata.push(myMap.get("40.0~60.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("60.0~80.0") != null) {
                        xdata.push(myMap.get("60.0~80.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("80.0~100.0") != null) {
                        xdata.push(myMap.get("80.0~100.0"));
                    } else {
                        xdata.push(0);
                    }
                }
                option = {
                    color: ['#23CBFE'],
                    title: {
                        text: '',
                        subtext: ''
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    legend: {
                        data: ['CPU利用率次数'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'value',
                        boundaryGap: [0, 0.01],
                        axisLabel: {
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'category',
                        axisLabel: {
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        splitLine: {
                            show: true
                        },
                        data: [
                            (100 - 0) / 5,
                            (100 - 0) / 5 * 2,
                            (100 - 0) / 5 * 3,
                            (100 - 0) / 5 * 4,
                            (100 - 0) / 5 * 5,
                        ]
                    },
                    series: [
                        {
                            name: 'CPU利用率次数',
                            type: 'bar',
                            barWidth: 30,
                            data: xdata,
                        }
                    ]
                };
                host_cpu_dzt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


//内存使用率折线图
// PM-00-01-002-01
function queryHostNc() {
    $.ajax({
        url: ctx + "/load/queryLoad",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-002-01" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list = map.list;
            var listTb = map.listTb;
            var listHb = map.listHb;
            var xdata = [];
            var ydata1 = [];
            var ydata2 = [];
            var ydata3 = [];
            var x_value = [];
            for (var i = 0; i < list.length; i++) {
                var a = list[i].AVG_VALUE;
                var b = listTb[i].AVG_VALUE;
                // var c = listHb[i].AVG_VALUE;
            }
            if (a == undefined || b == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_nc_syl_zxt").html(table);
            } else {
                if (DATE_TYPE == "showWeek") {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[2]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                } else if (DATE_TYPE == "showMonth") {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[2]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                } else if (DATE_TYPE == "showYear") {
                    for (var i = 0; i < list.length; i++) {
                        // xdata.push(list[i].DATA_TIME);
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[1]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        /* ydata3.push(listHb[i].AVG_VALUE);*/
                    }
                } else {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.replace(' ', '-').split("-");
                        xdata.push(x_value[3]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                }
                option = {
                    tooltip: {
                        trigger: 'axis',
                    },
                    legend: {
                        data: ['昨日', '同比', '环比'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            /*formatter:'{value} h',*/
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        data: xdata
                    }],
                    yAxis: [{
                        type: 'value',
                        max: 100,//Y轴最大值 不写的话自动调节
                        axisLabel: {
                            formatter: '{value} %',
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        }
                    }],
                    series: [
                        {
                            name: '昨日',
                            type: 'line',
                            color: '#EFB700',
                            data: ydata1
                        },
                        {
                            name: '同比',
                            type: 'line',
                            color: '#FF0A0E',
                            data: ydata2
                        },
                        {
                            name: '环比',
                            type: 'line',
                            color: '#0AFFBD',
                            data: ydata3
                        }
                    ]
                };
                host_nc_syl_zxt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


//内存使用率柱状图
//PM-00-01-002-01
function queryHostNcDzt() {
    $.ajax({
        url: ctx + "/load/queryNum",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-002-01" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var memoryNum = JSON.parse(data);
            var xdata = [];
            var num1 = '';
            var min_value = '';
            var max_value = '';
            var group = '';
            var p = [];
            var values = [];
            var result = [0, 0, 0, 0, 0];
            var temp = '';
            var temp1 = '';
            var hkh = '';
            var myMap = new Map();
            var sum = 0;
            for (var i = 0; i < memoryNum.length; i++) {
                var a = memoryNum[i].GROUP_VALUE;
            }
            if (a == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_nc_dzt").html(table);
            } else {
                if (DATE_TYPE != "showYear") {//，分割分完的截取每个元素的倒数第一个或者第二个双引号的值{"0.0~20.0":"289"，"20.0~40.0":"290，"40.0~60.0":"291"}
                    for (var i = 0; i < memoryNum.length; i++) {
                        hkh = memoryNum[i].GROUP_VALUE.substring(1, memoryNum[i].GROUP_VALUE.lastIndexOf('}'));
                        num1 = hkh.split(',');
                        min_value = memoryNum[i].Y_MIN_VALUE;
                        max_value = memoryNum[i].Y_MAX_VALUE;
                        group = memoryNum[i].VALUE_GROUP;
                        for (j = 0; j < num1.length; j++) {
                            temp = num1[j].substring(num1[j].lastIndexOf(':"') + 2, num1[j].lastIndexOf('"'));
                            temp1 = num1[j].substring(1, num1[j].lastIndexOf('":'));
                            myMap.set(temp1, temp);
                        }
                        if (myMap.get("0.0~20.0") != null) {
                            xdata.push(myMap.get("0.0~20.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("20.0~40.0") != null) {
                            xdata.push(myMap.get("20.0~40.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("40.0~60.0") != null) {
                            xdata.push(myMap.get("40.0~60.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("60.0~80.0") != null) {
                            xdata.push(myMap.get("60.0~80.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("80.0~100.0") != null) {
                            xdata.push(myMap.get("80.0~100.0"));
                        } else {
                            xdata.push(0);
                        }
                    }
                } else {
                    for (var i = 0; i < memoryNum.length; i++) {
                        hkh = memoryNum[i].GROUP_VALUE.substring(1, memoryNum[i].GROUP_VALUE.lastIndexOf('}'));
                        num1 = hkh.split(',');
                        min_value = memoryNum[i].Y_MIN_VALUE;
                        max_value = memoryNum[i].Y_MAX_VALUE;
                        group = memoryNum[i].VALUE_GROUP;
                        for (var j = 0; j < num1.length; j++) {
                            temp = num1[j].substring(num1[j].lastIndexOf(':"') + 2, num1[j].lastIndexOf('"'));
                            temp1 = num1[j].substring(1, num1[j].lastIndexOf('":'));
                            if (temp) {
                                sum = parseInt(sum) + parseInt(temp);
                            }
                            myMap.set(temp1, sum);
                        }
                    }
                    if (myMap.get("0.0~20.0") != null) {
                        xdata.push(myMap.get("0.0~20.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("20.0~40.0") != null) {
                        xdata.push(myMap.get("20.0~40.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("40.0~60.0") != null) {
                        xdata.push(myMap.get("40.0~60.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("60.0~80.0") != null) {
                        xdata.push(myMap.get("60.0~80.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("80.0~100.0") != null) {
                        xdata.push(myMap.get("80.0~100.0"));
                    } else {
                        xdata.push(0);
                    }
                }
                option = {
                    color: ['#23CBFE'],
                    title: {
                        text: '',
                        subtext: ''
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    legend: {
                        data: ['内存使用率次数'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'value',
                        boundaryGap: [0, 0.01],
                        axisLabel: {
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'category',
                        axisLabel: {
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        splitLine: {
                            show: true
                        },
                        data: [
                            (100 - 0) / 5,
                            (100 - 0) / 5 * 2,
                            (100 - 0) / 5 * 3,
                            (100 - 0) / 5 * 4,
                            (100 - 0) / 5 * 5,
                        ]
                    },
                    series: [
                        {
                            name: '内存使用率次数',
                            type: 'bar',
                            barWidth: 30,
                            data: xdata,
                        }
                    ]
                };
                host_nc_dzt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}

//磁盘使用率折线图
//PM-00-01-004-01
function queryHostCp() {
    $.ajax({
        url: ctx + "/load/queryLoad",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-004-01" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list = map.list;
            var listTb = map.listTb;
            var listHb = map.listHb;
            var xdata = [];
            var ydata1 = [];
            var ydata2 = [];
            var ydata3 = [];
            var x_value = [];
            for (var i = 0; i < list.length; i++) {
                var a = list[i].AVG_VALUE;
                var b = listTb[i].AVG_VALUE;
                // var c = listHb[i].AVG_VALUE;
            }
            if (a == undefined || b == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_cp_syl_zxt").html(table);
            } else {
                if (DATE_TYPE == "showWeek") {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[2]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                } else if (DATE_TYPE == "showMonth") {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[2]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                    /*  option.xAxis.axisLabel.formatter='{value} d';*/
                } else if (DATE_TYPE == "showYear") {
                    for (var i = 0; i < list.length; i++) {
                        // xdata.push(list[i].DATA_TIME);
                        x_value = list[i].DATA_TIME.split("-");
                        xdata.push(x_value[1]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        /* ydata3.push(listHb[i].AVG_VALUE);*/
                    }
                } else {
                    for (var i = 0; i < list.length; i++) {
                        x_value = list[i].DATA_TIME.replace(' ', '-').split("-");
                        xdata.push(x_value[3]);
                        ydata1.push(list[i].AVG_VALUE);
                        ydata2.push(listTb[i].AVG_VALUE);
                        ydata3.push(listHb[i].AVG_VALUE);
                    }
                }
                option = {
                    tooltip: {
                        trigger: 'axis',
                    },
                    legend: {
                        data: ['昨日', '同比', '环比'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [{
                        type: 'category',
                        boundaryGap: false,
                        axisLabel: {
                            /*formatter:'{value} h',*/
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        data: xdata
                    }],
                    yAxis: [{
                        type: 'value',
                        max: 100,//Y轴最大值 不写的话自动调节
                        axisLabel: {
                            formatter: '{value} %',
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        }
                    }],
                    series: [
                        {
                            name: '昨日',
                            type: 'line',
                            color: '#EFB700',
                            data: ydata1
                        },
                        {
                            name: '同比',
                            type: 'line',
                            color: '#FF0A0E',
                            data: ydata2
                        },
                        {
                            name: '环比',
                            type: 'line',
                            color: '#0AFFBD',
                            data: ydata3
                        }
                    ]
                };
                host_cp_syl_zxt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}

//磁盘使用率柱状图
// PM-00-01-004-01
function queryHostCpDzt() {
    $.ajax({
        url: ctx + "/load/queryNum",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-004-01" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var memoryNum = JSON.parse(data);
            var xdata = [];
            var num1 = '';
            var min_value = '';
            var max_value = '';
            var group = '';
            var p = [];
            var values = [];
            var result = [0, 0, 0, 0, 0];
            var temp = '';
            var temp1 = '';
            var hkh = '';
            var myMap = new Map();
            var sum = 0;
            for (var i = 0; i < memoryNum.length; i++) {
                var a = memoryNum[i].GROUP_VALUE;
            }
            if (a == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_cp_dzt").html(table);
            } else {
                if (DATE_TYPE != "showYear") {//，分割分完的截取每个元素的倒数第一个或者第二个双引号的值{"0.0~20.0":"289"，"20.0~40.0":"290，"40.0~60.0":"291"}
                    for (var i = 0; i < memoryNum.length; i++) {
                        hkh = memoryNum[i].GROUP_VALUE.substring(1, memoryNum[i].GROUP_VALUE.lastIndexOf('}'));
                        num1 = hkh.split(',');
                        min_value = memoryNum[i].Y_MIN_VALUE;
                        max_value = memoryNum[i].Y_MAX_VALUE;
                        group = memoryNum[i].VALUE_GROUP;
                        for (j = 0; j < num1.length; j++) {
                            temp = num1[j].substring(num1[j].lastIndexOf(':"') + 2, num1[j].lastIndexOf('"'));
                            temp1 = num1[j].substring(1, num1[j].lastIndexOf('":'));
                            myMap.set(temp1, temp);
                        }
                        if (myMap.get("0.0~20.0") != null) {
                            xdata.push(myMap.get("0.0~20.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("20.0~40.0") != null) {
                            xdata.push(myMap.get("20.0~40.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("40.0~60.0") != null) {
                            xdata.push(myMap.get("40.0~60.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("60.0~80.0") != null) {
                            xdata.push(myMap.get("60.0~80.0"));
                        } else {
                            xdata.push(0);
                        }
                        if (myMap.get("80.0~100.0") != null) {
                            xdata.push(myMap.get("80.0~100.0"));
                        } else {
                            xdata.push(0);
                        }
                    }
                } else {
                    for (var i = 0; i < memoryNum.length; i++) {
                        hkh = memoryNum[i].GROUP_VALUE.substring(1, memoryNum[i].GROUP_VALUE.lastIndexOf('}'));
                        num1 = hkh.split(',');
                        min_value = memoryNum[i].Y_MIN_VALUE;
                        max_value = memoryNum[i].Y_MAX_VALUE;
                        group = memoryNum[i].VALUE_GROUP;
                        for (var j = 0; j < num1.length; j++) {
                            temp = num1[j].substring(num1[j].lastIndexOf(':"') + 2, num1[j].lastIndexOf('"'));
                            temp1 = num1[j].substring(1, num1[j].lastIndexOf('":'));
                            if (temp) {
                                sum = parseInt(sum) + parseInt(temp);
                            }
                            myMap.set(temp1, sum);
                        }
                    }
                    if (myMap.get("0.0~20.0") != null) {
                        xdata.push(myMap.get("0.0~20.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("20.0~40.0") != null) {
                        xdata.push(myMap.get("20.0~40.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("40.0~60.0") != null) {
                        xdata.push(myMap.get("40.0~60.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("60.0~80.0") != null) {
                        xdata.push(myMap.get("60.0~80.0"));
                    } else {
                        xdata.push(0);
                    }
                    if (myMap.get("80.0~100.0") != null) {
                        xdata.push(myMap.get("80.0~100.0"));
                    } else {
                        xdata.push(0);
                    }
                }
                option = {
                    color: ['#23CBFE'],
                    title: {
                        text: '',
                        subtext: ''
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    legend: {
                        data: ['磁盘使用率次数'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'value',
                        boundaryGap: [0, 0.01],
                        axisLabel: {
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        splitLine: {
                            show: false
                        }
                    },
                    yAxis: {
                        type: 'category',
                        axisLabel: {
                            textStyle: {
                                color: '#AAAAAA'
                            }
                        },
                        splitLine: {
                            show: true
                        },
                        data: [
                            (100 - 0) / 5,
                            (100 - 0) / 5 * 2,
                            (100 - 0) / 5 * 3,
                            (100 - 0) / 5 * 4,
                            (100 - 0) / 5 * 5,
                        ]
                    },
                    series: [
                        {
                            name: '磁盘使用率次数',
                            type: 'bar',
                            barWidth: 30,
                            data: xdata
                        }
                    ]
                };
                host_cp_dzt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


// 文件系统使用率柱状图
// PM-00-01-004-03
function queryHostWjxt() {
    $.ajax({
        url: ctx + "/load/queryTableSpace",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&KPI_CODE=" + "PM-00-01-004-01" + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list = map.list;
            var xdata = [];
            var ydata = [];
            var x_value = [];
            for (var i = 0; i < list.length; i++) {
                var a = list[i].AVG_VALUE;
                var b = list[i].UNIT_ID;
            }
            if (a == undefined || b == undefined) {
                var table = "<h3 style='margin-top: 200px;padding-left: 340px;'>" + "暂无数据" + "</h3>";
                $("#host_wjxt_syl_zzt").html(table);
            } else {
                if (DATE_TYPE == "showYear") {
                    for (var i = 0; i < list.length; i++) {
                        // x_value = list[i].DATA_TIME.split("-");
                        // xdata.push(x_value[2]);
                        // x_value = list[i].DATA_TIME;
                        // xdata.push(x_value);
                        x_value = list[i].UNIT_ID.split(":");
                        xdata.push(x_value[3]);
                        ydata.push(list[i].AVG_VALUE);
                    }
                } else if (DATE_TYPE == "showMonth") {
                    for (var i = 0; i < list.length; i++) {
                        // x_value = list[i].DATA_TIME.split("-");
                        // xdata.push(x_value[2]);
                        // x_value = list[i].DATA_TIME;
                        // xdata.push(x_value);
                        x_value = list[i].UNIT_ID.split(":");
                        xdata.push(x_value[3]);
                        ydata.push(list[i].AVG_VALUE);
                    }
                } else if (DATE_TYPE == "showWeek") {
                    for (var i = 0; i < list.length; i++) {
                        // x_value = list[i].DATA_TIME.split("-");
                        // xdata.push(x_value[2]);
                        // x_value = list[i].DATA_TIME;
                        // xdata.push(x_value);
                        x_value = list[i].UNIT_ID.split(":");
                        xdata.push(x_value[3]);
                        ydata.push(list[i].AVG_VALUE);
                    }
                } else {
                    for (var i = 0; i < list.length; i++) {
                        // x_value = list[i].UNIT_ID.split("-");
                        // xdata.push(x_value[3]);
                        // alert(xdata);
                        x_value = list[i].UNIT_ID.split(":");
                        xdata.push(x_value[3]);
                        ydata.push(list[i].AVG_VALUE);
                    }
                }
                option = {
                    color: ['#23CBFE'],
                    title: {
                        text: '',
                        subtext: ''
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    legend: {
                        data: ['文件系统使用率'],
                        textStyle: {
                            color: '#AAAAAA'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: xdata,
                            axisTick: {
                                alignWithLabel: true
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            max: 100,
                            splitLine: {
                                show: true,
                            },
                            name: '',
                            nameTextStyle: {
                                color: '#000000',
                            },
                            axisLabel: {
                                formatter: '{value} %',
                                textStyle: {
                                    color: '#000000'
                                }
                            }
                        },
                    ],
                    series: [
                        {
                            name: '文件系统使用率',
                            type: 'bar',
                            barWidth: '60%',
                            data: ydata
                        }
                    ]
                };
                host_wjxt_syl_zzt.setOption(option);
            }
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}

//磁盘信息
//PM-00-01-003-03 磁盘IO速率        PM-00-01-003-01  磁盘忙百分比
function queryCp() {
    var str = cpList.toString();
    $.ajax({
        url: ctx + "/load/queryTable",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&RESU=" + str + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list1 = map["PM-00-01-003-03"];
            var list2 = map["PM-00-01-003-01"];
            var table = "";
            // console.log(list1.length);
            // console.log(list2.length);
            if (list1.length == 0 && list2.length == 0) {
                table +=
                    "<tr><th><span >" + "指标名" + "</span></th></tr>" +
                    "<tr><td><span >" + "暂无数据" + "</span></td></tr>";
            } else {
                table += "<tr>" +
                    "<th><span >" + "磁盘名称" + "</span></th>" +
                    "<th><span >" + list1[0].KPI_NAME + "</span></th>" +
                    "<th><span >" + list2[0].KPI_NAME + "</span></th>" +
                    "</tr>";
                if (DATE_TYPE == "showYear") {
                    var UnitIdList = new Array()   //结果ID列表
                    var succList2 = new Array();
                    var countList2 = new Array();
                    var AvgList2 = new Array(); //结果VALUE列表
                    var AvgList3 = new Array();

                    var map = new Map();            //结果map
                    var iSameLine = 0 //相同条数标志位
                    var SumValue2 = 0 //和值
                    var SumValue3 = 0

                    var gsuccValue = 0
                    var gcountValue = 0
                    var sTreeUnitId   //上一次ID

                    var str           //原始unit_id
                    var sUnitId       //名称
                    var succValue
                    var countValue
                    var AvgValue2
                    var AvgValue3

                    // console.log('列表条数为' + list1.length)
                    for (i = 1; i < list1.length; i++) {
                        str = list1[i].UNIT_ID;
                        sUnitId = str.split("-")[4];
                        succValue = parseInt(list1[i].SUCCESS_VALUE);
                        countValue = parseInt(list1[i].COUNT_VALUE);
                        AvgValue2 = parseInt(list2[i].AVG_VALUE)  //获取对应的avg_value/

                        if (i == 0) {                    //第一次进入标志位强制相同
                            sTreeUnitId = sUnitId;
                        }
                        if (sTreeUnitId == sUnitId) {   //本次循环获取id与上次相同累加并继续下次循环
                            gsuccValue = gsuccValue + succValue;
                            gcountValue = gcountValue + countValue;
                            SumValue2 = SumValue2 + AvgValue2;
                            SumValue3 = SumValue3 + AvgValue3;

                            iSameLine = iSameLine + 1     //桩相同条数
                            if (i == list1.length - 1) {   //循环到最后一次如果与上一次相同直接写出结果
                                UnitIdList.push(sTreeUnitId);
                                succList2.push(gsuccValue);
                                countList2.push(gcountValue);
                                AvgList2.push(SumValue2);
                                AvgList3.push(SumValue3);
                                map.set(sTreeUnitId, SumValue2)
                            }
                        } else {
                            UnitIdList.push(sTreeUnitId);
                            succList2.push(gsuccValue);
                            countList2.push(gcountValue);
                            AvgList2.push(SumValue2);
                            AvgList3.push(SumValue3);

                            map.set(sTreeUnitId, SumValue2);
                            iSameLine = 1
                            sTreeUnitId = sUnitId
                            gsuccValue = succValue;
                            gcountValue = countValue;
                            SumValue2 = AvgValue2
                            SumValue3 = AvgValue3;
                        }
                    }

                    for (var c = 1; c < UnitIdList.length; c++) {
                        table += "<tr>" +
                            "<td><span >" + UnitIdList[c] + "</span></td>" +
                            // "<td><span >" + succList2[c] / countList2[c] * 100 + "%" + "</span></td>" +
                            "<td><span >" + 0 / countList2[c] * 100 + "%" + "</span></td>" +
                            "<td><span >" + AvgList2[c] + "</span></td>" +
                            "</tr>";

                    }
                    $("#row6").css("height", UnitIdList.length * 34 + 14 + 34 + 34);
                } else {
                    for (var i = 1; i < list1.length; i++) {
                        var str = list1[i].UNIT_ID;
                        var PORTNAME = str.split("-")[4];
                        if (list1[i].SUCCESS_VALUE == undefined) {
                            table += "<tr>" +
                                "<td><span >" + PORTNAME + "</span></td>" +
                                "<td><span >" + parseInt((0 / list1[i].COUNT_VALUE) * 100) + "%" + "</span></td>" +
                                "<td><span >" + list2[i].AVG_VALUE + "</span></td>" +
                                "</tr>";
                        } else {
                            table += "<tr>" +
                                "<td><span >" + PORTNAME + "</span></td>" +
                                "<td><span >" + parseInt((list1[i].SUCCESS_VALUE / list1[i].COUNT_VALUE) * 100) + "%" + "</span></td>" +
                                "<td><span >" + list2[i].AVG_VALUE + "</span></td>" +
                                "</tr>";
                        }
                    }
                    $("#row6").css("height", list1.length * 34 + 14 + 34 + 34);
                }
            }
            $("#cp").append(table);
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


//逻辑卷状态信息
//FM-00-01-001-14   逻辑卷状态
function queryLjjInfo() {
    var str = ljjList.toString();
    $.ajax({
        url: ctx + "/load/queryTable",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&RESU=" + str + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list1 = map["FM-00-01-001-14"];
            var table = "";
            if (list1.length == 0) {
                table +=
                    "<tr><th><span >" + "指标名" + "</span></th></tr>" +
                    "<tr><td><span >" + "暂无数据" + "</span></td></tr>";
            } else {
                table += "<tr>" +
                    "<th><span >" + "逻辑卷名称" + "</span></th>" +
                    "<th><span >" + list1[0].KPI_NAME + "</span></th>" +
                    "</tr>";
                if (DATE_TYPE == "showYear") {
                    var UnitIdList = new Array()   //结果ID列表
                    var succList2 = new Array();
                    var countList2 = new Array();
                    var AvgList2 = new Array(); //结果VALUE列表

                    var map = new Map();            //结果map
                    var iSameLine = 0 //相同条数标志位
                    var SumValue2 = 0 //和值

                    var gsuccValue = 0
                    var gcountValue = 0
                    var sTreeUnitId   //上一次ID

                    var str           //原始unit_id
                    var sUnitId       //名称
                    var succValue
                    var countValue
                    var AvgValue2

                    for (i = 1; i < list1.length; i++) {
                        str = list1[i].UNIT_ID;
                        sUnitId = str.split("-")[4];
                        succValue = parseInt(list1[i].SUCCESS_VALUE);
                        countValue = parseInt(list1[i].COUNT_VALUE);

                        if (i == 0) {                    //第一次进入标志位强制相同
                            sTreeUnitId = sUnitId;
                        }
                        if (sTreeUnitId == sUnitId) {   //本次循环获取id与上次相同累加并继续下次循环
                            gsuccValue = gsuccValue + succValue;
                            gcountValue = gcountValue + countValue;
                            SumValue2 = SumValue2 + AvgValue2;

                            iSameLine = iSameLine + 1     //桩相同条数
                            // console.log(i + 1)
                            if (i == list1.length - 1) {   //循环到最后一次如果与上一次相同直接写出结果
                                UnitIdList.push(sTreeUnitId);
                                succList2.push(gsuccValue);
                                countList2.push(gcountValue);
                                AvgList2.push(SumValue2);
                                map.set(sTreeUnitId, SumValue2)
                            }
                        } else {
                            UnitIdList.push(sTreeUnitId);
                            succList2.push(gsuccValue);
                            countList2.push(gcountValue);
                            AvgList2.push(SumValue2);

                            map.set(sTreeUnitId, SumValue2);
                            iSameLine = 1
                            sTreeUnitId = sUnitId
                            gsuccValue = succValue;
                            gcountValue = countValue;
                            SumValue2 = AvgValue2
                        }
                    }

                    for (var c = 1; c < UnitIdList.length; c++) {
                        table += "<tr>" +
                            "<td><span >" + UnitIdList[c] + "</span></td>" +
                            "<td><span >" + parseInt(succList2[c] / countList2[c] * 100) + "%" + "</span></td>" +
                            "</tr>";
                    }
                    $("#row7").css("height", UnitIdList.length * 34 + 14 + 34 + 34);
                } else {
                    for (var i = 1; i < list1.length; i++) {
                        var str = list1[i].UNIT_ID;
                        var PORTNAME = str.split("-")[4];
                        if (list1[i].SUCCESS_VALUE == undefined) {
                            table += "<tr>" +
                                "<td><span >" + PORTNAME + "</span></td>" +
                                "<td><span >" + 0 + "%" + "</span></td>" +
                                "</tr>";
                        } else {
                            table += "<tr>" +
                                "<td><span >" + PORTNAME + "</span></td>" +
                                "<td><span >" + parseInt((list1[i].SUCCESS_VALUE / list1[i].COUNT_VALUE) * 100) + "%" + "</span></td>" +
                                "</tr>";
                        }

                    }
                    $("#row7").css("height", list1.length * 34 + 14 + 34 + 34);
                }
            }
            $("#ljj").append(table);
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


//CPU状态信息
//FM-00-01-001-15  CPU状态
function queryCpu() {
    var str = cpuStateList.toString();
    $.ajax({
        url: ctx + "/load/queryTable",
        type: "post",
        data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&RESU=" + str + "&DATE_TYPE=" + DATE_TYPE + "&CLASS_NAME=" + CLASS_NAME,
        success: function (data) {
            var map = JSON.parse(data);
            var list1 = map["FM-00-01-001-15"];
            var table = "";
            if (list1.length == 0) {
                table +=
                    "<tr><th><span >" + "指标名" + "</span></th></tr>" +
                    "<tr><td><span >" + "暂无数据" + "</span></td></tr>";
            } else {
                table += "<tr>" +
                    "<th><span >" + "CPU名称" + "</span></th>" +
                    "<th><span >" + list1[0].KPI_NAME + "</span></th>" +
                    "</tr>";
                if (DATE_TYPE == "showYear") {
                    var UnitIdList = new Array()   //结果ID列表
                    var succList2 = new Array();
                    var countList2 = new Array();
                    var AvgList2 = new Array(); //结果VALUE列表
                    var map = new Map();            //结果map
                    var iSameLine = 0 //相同条数标志位
                    var SumValue2 = 0 //和值
                    var gsuccValue = 0
                    var gcountValue = 0
                    var sTreeUnitId   //上一次ID
                    var str           //原始unit_id
                    var sUnitId       //名称
                    var succValue
                    var countValue
                    var AvgValue2
                    for (i = 1; i < list1.length; i++) {
                        str = list1[i].UNIT_ID;
                        sUnitId = str.split("-")[4];
                        succValue = parseInt(list1[i].SUCCESS_VALUE);
                        countValue = parseInt(list1[i].COUNT_VALUE);
                        if (i == 0) {                    //第一次进入标志位强制相同
                            sTreeUnitId = sUnitId;
                        }
                        if (sTreeUnitId == sUnitId) {   //本次循环获取id与上次相同累加并继续下次循环
                            gsuccValue = gsuccValue + succValue;
                            gcountValue = gcountValue + countValue;
                            SumValue2 = SumValue2 + AvgValue2;
                            iSameLine = iSameLine + 1     //桩相同条数
                            if (i == list1.length - 1) {   //循环到最后一次如果与上一次相同直接写出结果
                                UnitIdList.push(sTreeUnitId);
                                succList2.push(gsuccValue);
                                countList2.push(gcountValue);
                                AvgList2.push(SumValue2);
                                map.set(sTreeUnitId, SumValue2)
                            }
                        } else {
                            UnitIdList.push(sTreeUnitId);
                            succList2.push(gsuccValue);
                            countList2.push(gcountValue);
                            AvgList2.push(SumValue2);
                            map.set(sTreeUnitId, SumValue2);
                            iSameLine = 1
                            sTreeUnitId = sUnitId
                            gsuccValue = succValue;
                            gcountValue = countValue;
                            SumValue2 = AvgValue2
                        }
                    }
                    for (var c = 1; c < UnitIdList.length; c++) {
                        table += "<tr>" +
                            "<td><span >" + UnitIdList[c] + "</span></td>" +
                            "<td><span >" + succList2[c] / countList2[c] * 100 + "%" + "</span></td>" +
                            "</tr>";
                    }
                    $("#row8").css("height", UnitIdList.length * 34 + 14 + 34 + 34);
                } else {
                    for (var i = 1; i < list1.length; i++) {
                        var str = list1[i].UNIT_ID;
                        var PORTNAME = str.split("-")[4];
                        table += "<tr>" +
                            "<td><span >" + PORTNAME + "</span></td>" +
                            "<td><span >" + parseInt((list1[i].SUCCESS_VALUE / list1[i].COUNT_VALUE) * 100) + "%" + "</span></td>" +
                            "</tr>";
                    }
                    $("#row8").css("height", list1.length * 34 + 14 + 34 + 34);
                }
            }
            $("#state").append(table);
        }, error: function (textStatus) {
            console.log("error:" + textStatus.status);
        }
    });
}


//换页空间信息
//PM-00-01-001-19       PM-00-01-001-20              PM-00-01-001-21                         PM-00-01-001-22        PM-00-01-001-23
//换页空间大小          换页空间使用率               换页空间是否活动                       换页空间是否自动        换页空间类型
// function queryHPageInfo() {
//     var str = pageList.toString();
//     $.ajax({
//         url: ctx + "/load/queryTable",
//         type: "post",
//         data: "EXT_UNIT_ID=" + EXT_UNIT_ID + "&RESU=" + str + "&DATE_TYPE=" + DATE_TYPE,
//         success: function (data) {
//             var map = JSON.parse(data);
//             var list1 = map["PM-00-01-001-19"];
//             var list2 = map["PM-00-01-001-20"];
//             var table = "";
//             if (list1.length == 0 && list2.length == 0) {
//                 table +=
//                     "<tr><th><span >" + "指标名" + "</span></th></tr>" +
//                     "<tr><td><span >" + "暂无数据" + "</span></td></tr>";
//             } else {
//                 table +=
//                     "<tr><th><span >" + "换页空间物理卷" + "</span></th>" +
//                     "<th><span >" + list1[0].KPI_NAME + "</span></th>" +
//                     "<th><span >" + list2[0].KPI_NAME + "</span></th>" +
//                     "</tr>";
//                 if (DATE_TYPE == "showYear") {
//                     var UnitIdList = new Array()   //结果ID列表
//                     var succList2 = new Array();
//                     var countList2 = new Array();
//                     var AvgList2 = new Array() //结果VALUE列表
//                     var map = new Map()            //结果map
//                     var iSameLine = 0 //相同条数标志位
//                     var SumValue2 = 0 //和值
//                     var gsuccValue = 0
//                     var gcountValue = 0
//                     var sTreeUnitId   //上一次ID
//
//                     var str           //原始unit_id
//                     var sUnitId       //名称
//                     var succValue
//                     var countValue
//                     var AvgValue2
//
//                     for (i = 1; i < list1.length; i++) {
//                         str = list1[i].UNIT_ID;
//                         sUnitId = str.split("-")[4];
//                         succValue = parseInt(list1[i].SUCCESS_VALUE);
//                         countValue = parseInt(list1[i].COUNT_VALUE);
//                         AvgValue2 = parseInt(list2[i].AVG_VALUE)  //获取对应的avg_value/
//                         if (i == 0) {                    //第一次进入标志位强制相同
//                             sTreeUnitId = sUnitId;
//                         }
//                         if (sTreeUnitId == sUnitId) {   //本次循环获取id与上次相同累加并继续下次循环
//                             gsuccValue = gsuccValue + succValue;
//                             gcountValue = gcountValue + countValue;
//                             SumValue2 = SumValue2 + AvgValue2;
//
//                             iSameLine = iSameLine + 1     //桩相同条数
//                             // console.log(i + 1)
//                             if (i == list1.length - 1) {   //循环到最后一次如果与上一次相同直接写出结果
//                                 UnitIdList.push(sTreeUnitId);
//                                 succList2.push(gsuccValue);
//                                 countList2.push(gcountValue);
//                                 AvgList2.push(SumValue2);
//
//                                 map.set(sTreeUnitId, SumValue2)
//                             }
//                         } else {
//                             UnitIdList.push(sTreeUnitId);
//                             succList2.push(gsuccValue);
//                             countList2.push(gcountValue);
//                             AvgList2.push(SumValue2);
//
//                             map.set(sTreeUnitId, SumValue2);
//                             iSameLine = 1
//                             sTreeUnitId = sUnitId
//                             gsuccValue = succValue;
//                             gcountValue = countValue;
//                             SumValue2 = AvgValue2
//                         }
//                     }
//
//                     for (var c = 1; c < UnitIdList.length; c++) {
//                         table += "<tr>" +
//                             "<td><span >" + UnitIdList[c] + "</span></td>" +
//                             // "<td><span >" + succList2[c] / countList2[c] * 100 + "%" + "</span></td>" +
//                             "<td><span >" + 0 + "%" + "</span></td>" +
//                             "<td><span >" + AvgList2[c] + "</span></td>" +
//                             "</tr>";
//                     }
//
//                     $("#row9").css("height", UnitIdList.length * 34 + 14 + 34 + 34);
//
//                 } else {
//                     for (var i = 1; i < list1.length; i++) {
//                         var str = list1[i].UNIT_ID;
//                         var PORTNAME = str.split("-")[4];
//                         if (list1[i].SUCCESS_VALUE == undefined) {
//                             table += "<tr>" +
//                                 "<td><span >" + PORTNAME + "</span></td>" +
//                                 "<td><span >" + 0 + "%" + "</span></td>" +
//                                 "<td><span >" + list2[i].AVG_VALUE + "</span></td>" +
//                                 "</tr>";
//                         } else {
//                             table += "<tr>" +
//                                 "<td><span >" + PORTNAME + "</span></td>" +
//                                 "<td><span >" + parseInt((list1[i].SUCCESS_VALUE / list1[i].COUNT_VALUE) * 100) + "%" + "</span></td>" +
//                                 "<td><span >" + list2[i].AVG_VALUE + "</span></td>" +
//                                 "</tr>";
//                         }
//                     }
//
//                     $("#row9").css("height", list1.length * 34 + 14 + 34 + 34);
//                 }
//             }
//             $("#info").append(table);
//         }, error: function (textStatus) {
//             console.log("error:" + textStatus.status);
//         }
//     });
// }


// //按钮事件
// $(".rad_1").click(function () {
//     var id = $(this).attr('for');
//     // alert(id);
//     host_ping_ybp.clear();//PING
//     host_syslog_ybp.clear();//SYSLOG
//     host_cpu_syl_zxt.clear();//CPU
//     host_cpu_dzt.clear();//CPU
//     host_nc_syl_zxt.clear();//内存
//     host_nc_dzt.clear();//内存
//     host_cp_syl_zxt.clear();//磁盘
//     host_cp_dzt.clear();//磁盘
//     host_wjxt_syl_zzt.clear();//文件系统
//
//     $("#host_info tr").remove();
//     // $("#host_info1 tr").remove();
//     $("#cp tr").remove();//表格id+tr
//     $("#ljj tr").remove();//表格id+tr
//     $("#state tr").remove();//表格id+tr
//     $("#info tr").remove();//表格id+tr
//
//
//     HostInformationViewController(id);
//     queryHostPing(id);
//     queryHostSyslog(id);
//     queryHostCpu(id);
//     queryHostCpuDzt(id);
//     queryHostNc(id);
//     queryHostNcDzt(id);
//     queryHostCp(id);
//     queryHostCpDzt(id);
//     queryHostWjxt(id);
//     queryCp(id);
//     queryLjjInfo(id);
//     queryCpu(id);
//     queryHPageInfo(id);
// });


